package com.example.api.factory;


import com.example.api.RemoteJudgeService;
import com.example.api.domain.JudgeResult;
import com.example.api.domain.JudgeSubmitDTO;
import com.example.core.domain.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

@Slf4j
public class RemoteJudgeFallbackFactory implements FallbackFactory<RemoteJudgeService> {

    @Override
    public RemoteJudgeService create(Throwable cause) {
        log.error("判题服务调用失败:{}", cause.getMessage());
        return new RemoteJudgeService() {
            @Override
            public R<JudgeResult> doJudge(JudgeSubmitDTO judgeSubmitDTO, String source) {
                return R.fail("调用判题功能失败：" + cause.getMessage());
            }
        };
    }
}
